#!/bin/bash
binddn='cn=Manager,dc=jhc,dc=cn'
pwdfile=~/.ldappwd
basedn='dc=jhc,dc=cn'
uid=$1

username=$(ldapsearch -x -y "$pwdfile" -D "$binddn" -b "$basedn" -s sub "(uid=$uid)" | grep '^cn:: ' | sed 's/^cn:: //')
echo -n "$username" | base64 -d
echo ""
